package com.youbug.mall.product_pms.feign.impl;

import com.youbug.common.to.PmsSkuInfoTo;
import com.youbug.common.vo.R;
import com.youbug.mall.product_pms.entity.PmsSkuInfo;
import com.youbug.mall.product_pms.service.IPmsSkuInfoService;
import com.youbug.mall.seckill.feign.ISeckillProductFeignService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SeckillProductFeignServiceImpl implements ISeckillProductFeignService {
    @Autowired
    private IPmsSkuInfoService pmsSkuInfoService;
    @Override
    public R<PmsSkuInfoTo> getSkuInfo(Long skuId) {

        PmsSkuInfo skuInfo = pmsSkuInfoService.getById(skuId);
        if(skuInfo != null){
            PmsSkuInfoTo infoTo = new PmsSkuInfoTo();
            BeanUtils.copyProperties(skuInfo, infoTo);
            return R.ok(infoTo);
        }
        return R.fail();
    }
}
